//
// Created by Wei on 2022/5/15.
//

#ifndef B_PLUS_DB_COMPACT_HEADER_H
#define B_PLUS_DB_COMPACT_HEADER_H

#include <cstdio>

typedef struct COMPACT_HEADER {
private:
    //五个字节存储头信息

    //预留 1bit
    //delete_mask 标记是否删除 1bit
    //min_rec_mask 非叶子节点的最小记录标记 1bit
    //n_owned 当前记录分组的记录数 4bit

    //heap_no 当前记录在堆的位置 13bit
    //record_type 记录类型 0:普通记录 1:非叶子节点 2:最小记录 3:最大记录 3bit

    //next_record 下一条记录相对位置 16bit
    unsigned char head_info[5];
public:
    void set_delete_mask(bool flag);

    bool isDeleted();

    void set_min_rec_mask(bool flag);

    bool isMinRec();

    void set_n_owned(unsigned char n_owned);

    unsigned char get_n_owned();

    void set_heap_no(unsigned short heap_no);

    unsigned short get_heap_no();

    void set_record_type(unsigned char record_type);

    unsigned char get_record_type();

    void set_next_record(unsigned short next_record);

    unsigned short get_next_record();

    void set(bool delete_mask,
            bool min_rec_mask,
            unsigned char n_owned,
            unsigned short heap_no,
            unsigned char record_type,
            unsigned short next_record);
} COMPACT_HEADER;

#endif //B_PLUS_DB_COMPACT_HEADER_H
